package com.lanou.dllo.findfood.tools;

import android.annotation.SuppressLint;  
import android.content.Context;  
import android.view.Gravity;  
import android.view.LayoutInflater;  
import android.view.View;  
import android.view.ViewGroup;  
import android.widget.ImageView;  
import android.widget.TextView;  
import android.widget.Toast;

import com.lanou.dllo.findfood.R;

import static com.lanou.dllo.findfood.R.color.common_warning_color;

//自定义toast
public class ToastCommon {
	 private static ToastCommon toastCommom;
    private Toast toast;
	    private ToastCommon(){  
	    }  
	    public static ToastCommon createToastConfig(){  
	        if (toastCommom==null) {  
	            toastCommom = new ToastCommon();  
	        }  
	        return toastCommom;  
	    }  
	    @SuppressLint("ResourceAsColor")
        //调用的方法
		public void ToastShow(Context context,ViewGroup root,String tvString){  
	        View layout = LayoutInflater.from(context).inflate(R.layout.toast,root);  
	        TextView text = (TextView) layout.findViewById(R.id.text);
	        ImageView mImageView = (ImageView) layout.findViewById(R.id.iv);  
	      //  mImageView.setBackgroundResource(R.mipmap.app_icon_longin_eye);
	        text.setText(tvString);  
	      //  text.setTextColor(common_warning_color);
	        toast = new Toast(context);  
	        toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);  
	        toast.setDuration(Toast.LENGTH_SHORT);  
	        toast.setView(layout);  
	        toast.show();  
	    }  

	      
}
